namespace groopServer.Common.Persistence {
    using System;
    using System.Web;
    using NHibernate;

    public class FTSessionBuilderModule : IHttpModule {
        #region IHttpModule Members

        public void Init(HttpApplication context) {
            context.EndRequest += context_EndRequest;
        }

        public void Dispose() {}

        #endregion

        private static void context_EndRequest(object sender, EventArgs e) {
            var builder = new HybridSessionBuilder();
            ISession session = builder.GetExistingWebSession();

            if (session != null) {
                session.Dispose();
            }
        }
    }
}